- /* snmnorm.cpp by K.Tsuru */
- // function ID = 105 DRADIX, BRADIX
- #ifndef SN_H
- #include "sn.h"
- #endif
- /*********************************************************
- SNumber class
- It provides the normalization.
- The position of figures must be determined before calling.
- **********************************************************/
- static const char* func = "Normalize";
- void SNumber::Normalize()
- {
- fType w, radix = Radix();
- register uint i;
- fType* v = figure.Elements();
- #ifndef NDEBUG
- figure(aHead);
- #endif
- if(type & DEC_INT){
- for(i = aTail; i < aHead; i++){
- if( v[i] < radix) continue;
- w = v[i];
- v[i] = w % radix;
- v[i+1] += w / radix;
- }
- if(v[aHead] >= radix){
- w = v[aHead];
- Reserve(aHead+1); //checking of OVERFLOW_ERR is done in valloc()
- v = figure.Elements();
- figure[aHead] = w % radix;
- figure[aHead+1] = w / radix;
- aHead++;
- }
- while(!v[aTail]) aTail++;
- } else {
- for(i = aHead; i > aTail; i--){
- if( v[i] < radix) continue;
- w = v[i];
- v[i] = w % radix;
- v[i-1] += w / radix;
- }
- if(v[aTail] >= radix){
- //It cannot change the value of SDouble::rdxExp.
- if(aTail == 0) SetError(OVERFLOW_ERR, func, 105);
- w = v[aTail];
- figure[aTail] = w % radix;
- figure[aTail-1] = w / radix;
- aTail--;
- }
- while(!v[aHead]) aHead--;
- }
- //You must call SDouble::Reform() for the real type.
- }
snmnorm.cpp : last modifiled at 2017/03/17 11:10:49(1,404 bytes)
created at 2016/04/11 11:36:47
The creation time of this html file is 2017/10/27 10:59:17 (Fri Oct 27 10:59:17 2017).